package cn.shop.alibaba.controller;

import cn.shop.alibaba.dto.OderParams;
import cn.shop.alibaba.resp.Result;
import cn.shop.alibaba.service.OrderService;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class OrderController {
    @Autowired
    @Qualifier(value = "orderServiceV4")
    private OrderService orderService;

    @GetMapping(value = "/submit_order")
    public String submitOrder(OderParams oderParams){
        log.info("提交订单时传递的参数:{}", JSONObject.toJSONString(oderParams));
        orderService.saveOrder(oderParams);
        return "success";
    }

    /**
     * 压力测试
     * @return
     */
    @GetMapping(value = "/concurrent_request")
    public String concurrentRequest(){
        log.info("测试业务在高并发场景下是否存在问题");
        return "haha";
    }

    /**
     * 测试sentinel
     * @return
     */
    @GetMapping(value = "/test_sentinel")
    public String testSentinel(){
        log.info("测试Sentinel");
        return "sentinel";
    }
}
